home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / qwindows.arc / SAVESCRN.8 < prev    next >
Encoding:
Text File  |  1987-04-03  |  1.9 KB  |  57 lines

  1. ;This is a procedure callable from QBasic to save the current screen to a
  2. ;buffer passed as the address of a 2000 integer array.
  3.  
  4. Name      Savescrn            ;Name used at link time
  5. Public    Savescrn            ;Only label that is public
  6.  
  7. Savescrn: ORG       0         ;Since will be linked later
  8.  
  9.           jmp  short Getpara  ;Get parameters
  10.  
  11. Vidmem    equ       0B800h                   ;Video page 1 segment
  12. Scrnbuf:  dw        ?                        ;Screen buffer location from Basic
  13. Msg1:     db   'Not in a color mode now.$'   ;Error message
  14.           
  15. Getpara:  push      bp
  16.           mov       bp,sp
  17.           push      es
  18.           push      ds
  19.           push      cs        ;es=cs
  20.           pop       es
  21.           cld
  22.           mov       bx,[bp+6]     ;Get address of screen buffer location in ds
  23.           mov       ax,ds:[bx]    ;Get location of screen buffer in ds
  24.           mov       cs:[Scrnbuf],ax
  25.  
  26. ;Get current video mode and page
  27.           mov  ah,15     ;Get current video mode
  28.           int  10h
  29.           cmp  al,2      ;Mode 2?
  30.           je   Color     ;Yes
  31.           cmp  al,3      ;Mode 3?
  32.           je   Color     ;Yes
  33.           mov  dx,Msg1   ;No, print message
  34.           mov  ah,9
  35.           int  21h
  36. Exit:                           ;Return to Basic
  37.           pop  ds
  38.           pop  es
  39.           pop  bp
  40.           retf 2         
  41.  
  42.  
  43. Color:                   ;Find video memory.
  44.           mov  bl,0      ;bx=page offset
  45.           add  bx,Vidmem ;Add page 0 address
  46.  
  47. ;Save current screen.
  48.           push ds        ;Set es for Basic ds
  49.           pop  es
  50.           mov  ds,bx     ;Set ds for screen memory
  51.           mov  di,cs:[Scrnbuf] ;Point to buffer in Basic ds
  52.           mov  si,0      ;Start of screen
  53.           mov  cx,80*25  ;Words to move
  54.           rep  movsw     ;Move them
  55.           jmp  Exit
  56. 
  57.